package com.cy.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @author qyq
 * @create 2021-03-01-12:45
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult implements Serializable {
    private Integer status; //200表示成功，201表示失败
    private String msg;     //服务器返回的提示信息
    private Object data;    //服务器返回的数据
    //定义JsonResult封装对象



    public static JsonResult fail(){
        return new JsonResult(201,"服务器执行失败",null);
    }

    public static JsonResult success(Object data){
        return new JsonResult(200,"服务器执行成功",data);
    }

    public static JsonResult success(String msg, Object data){
        return new JsonResult(200,msg,data);
    }
}
